package com.xingdata.jjxc.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.ConnectivityManager;

import com.xingdata.jjxc.activity.TokenEntity;
import com.xingdata.jjxc.enty.NotificationEntity;
import com.xingdata.jjxc.enty.UserEntity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
 * 系统相关信息SystemInfo公共类
 * public class SystemInfo{}
 * @author ysc
 */
public class SystemInfo {
	/**
	 * true 为正式环境 false为测试环境
	 */
	public static boolean isDebug = true;
	
	public static boolean isHUD = false;
	private static  String SendPORT = "16001";
	private static String HUD_System_Port="16069";
	private static  String ReceivePORT = "16000";
	private static String ServerPORT="9090";
	public static Object objectsynchronized = new Object();
	public static  boolean isContent=false;
	public static long timeOut=20*1000;
	public static String Version_HUD="";
	public static String Hud_version;
	

	/**
	 * 天气对照码表
	 */
	public static String JSONNAME = "dTable.json";
	public static HashMap<String, NotificationEntity> messageCodeMap = new HashMap<String, NotificationEntity>();
	public static Boolean isConnect = false;
	// 缓存MAC地址
	public static String HUD_MAC = "";
	public static String City = "";
	public static String Weather = "";
	public static String Temperature = "";
	private static TokenEntity tokenEntity;
//	/**
//	 * 设置列表
//	 */
//	public static String[] Settings = { Common.BRIGHTNESS_SWITCH,
//			Common.CALLUP_SWITCH, Common.MMS_SWITCH, Common.WeiXin_SWITCH,
//			Common.QQ_SWITCH, Common.WangXin_SWITCH };
	private static UserEntity UserInfo;

	public static final int DataBaseVersion = 1;
	// 数据库名
	public static final String DataBaseName = "jjxc_db";
	// 数据库名
	public static final String UpdateDBSQL = "dbscript.json";

	/**返回return UserInfo（此处UserInfo是UserEntity的类名）*/
	public static UserEntity getUserInfo() {
		return UserInfo;
	}

	public static void setUserInfo(UserEntity userInfo) {
		UserInfo = userInfo;
	}
	
	public static TokenEntity getTokenEntity() {
		return tokenEntity;
	}

	public static void setTokenEntity(TokenEntity tokenEntity) {
		SystemInfo.tokenEntity = tokenEntity;
	}

	public static String getSendPORT() {
		return isHUD ? SendPORT : ReceivePORT;
	}

	public static String getReceivePORT() {
		return isHUD ? ReceivePORT :SendPORT ;
	}
	
	public static String getServerPORT() {
		return ServerPORT;
	}

	
	
	public static String getHUD_System_Port() {
		return HUD_System_Port;
	}



	/**
	 * 是否登录
	 * 
	 * @return
	 */
	public static boolean isLogin() {
		return !(UserInfo == null || UserInfo.getMobile() == null || UserInfo
				.getMobile().length() == 0);
	}

	public static String getAPKVersionName(Context context) {
		// 获取应用包信息
		PackageInfo info = null;
		try {
			info = context.getPackageManager().getPackageInfo(
					context.getPackageName(), 0);
		} catch (NameNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return info.versionName;
	}

	public static boolean isNetworkConnected(Context context) {
		ConnectivityManager cwjManager = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		cwjManager.getActiveNetworkInfo();
		boolean netSataus = true;
		if (cwjManager.getActiveNetworkInfo() == null) {

			netSataus = false;
		}
		return netSataus;
	}


	/**
	 * 创建SQL表
	 * @return
	 */
	private static List<String> GetCreateTableSQL() {
		List<String> objSQLList = new ArrayList<String>();
		// 导航搜索记录
		objSQLList
				.add("create table E_navi_history (user_id text,loca_id text,loca_nickname text,loca_areaid text,loca_address text,loca_lng text,loca_lat text,create_time text);");
		// 导航搜索记录
				objSQLList
						.add("create table E_hud_auth (hud_code text,userid text,crt_time text);");
		
		return objSQLList;

	}
}
